<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="GitHub,Hexo,Next," />





  <link rel="alternate" href="/atom.xml" title="鹿台" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="前言
GitHub：相当于一个服务器，相比于国内的一些博客服务提供商要稳定安全，且靠谱的多。不会昨天还高喊「永久免费」今天就告诉你马上要停止服务了，快转移资料吧
Hexo：相当于博客框架（基于 Node.js），快速、简单，扩展插件较多，支持 Markdown 格式渲染
Next：博客主题，简洁、文档齐全且可定制性强，最重要的是全中文文档

这三个组合在一起，真的是非常赞！
更新记录2016-11">
<meta property="og:type" content="article">
<meta property="og:title" content="GitHub+Hexo+Next 搭建静态博客">
<meta property="og:url" content="https://shynhan.github.io/2016/11/20/GitHub-Hexo-Next-搭建静态博客/index.html">
<meta property="og:site_name" content="鹿台">
<meta property="og:description" content="前言
GitHub：相当于一个服务器，相比于国内的一些博客服务提供商要稳定安全，且靠谱的多。不会昨天还高喊「永久免费」今天就告诉你马上要停止服务了，快转移资料吧
Hexo：相当于博客框架（基于 Node.js），快速、简单，扩展插件较多，支持 Markdown 格式渲染
Next：博客主题，简洁、文档齐全且可定制性强，最重要的是全中文文档

这三个组合在一起，真的是非常赞！
更新记录2016-11">
<meta property="og:image" content="http://p1.bpimg.com/575659/27bc19d2ab5125c0.jpg">
<meta property="og:image" content="http://p1.bpimg.com/575659/1e5307d93ab5dd9e.jpg">
<meta property="og:updated_time" content="2016-11-28T12:46:23.597Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="GitHub+Hexo+Next 搭建静态博客">
<meta name="twitter:description" content="前言
GitHub：相当于一个服务器，相比于国内的一些博客服务提供商要稳定安全，且靠谱的多。不会昨天还高喊「永久免费」今天就告诉你马上要停止服务了，快转移资料吧
Hexo：相当于博客框架（基于 Node.js），快速、简单，扩展插件较多，支持 Markdown 格式渲染
Next：博客主题，简洁、文档齐全且可定制性强，最重要的是全中文文档

这三个组合在一起，真的是非常赞！
更新记录2016-11">
<meta name="twitter:image" content="http://p1.bpimg.com/575659/27bc19d2ab5125c0.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '11769200',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://shynhan.github.io/2016/11/20/GitHub-Hexo-Next-搭建静态博客/"/>





  <title> GitHub+Hexo+Next 搭建静态博客 | 鹿台 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">鹿台</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">台高插汉 榭耸凌云</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="https://shynhan.github.io/2016/11/20/GitHub-Hexo-Next-搭建静态博客/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="玄鸟">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/uploads/avatar.png">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="鹿台">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="鹿台" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                GitHub+Hexo+Next 搭建静态博客
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2016-11-20T01:57:37+08:00">
                2016-11-20
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/教程/" itemprop="url" rel="index">
                    <span itemprop="name">教程</span>
                  </a>
                </span>

                
                
                  ， 
                
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/教程/原创教程/" itemprop="url" rel="index">
                    <span itemprop="name">原创教程</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <a href="/2016/11/20/GitHub-Hexo-Next-搭建静态博客/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/11/20/GitHub-Hexo-Next-搭建静态博客/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          
             <span id="/2016/11/20/GitHub-Hexo-Next-搭建静态博客/" class="leancloud_visitors" data-flag-title="GitHub+Hexo+Next 搭建静态博客">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">阅读次数 </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><ul>
<li>GitHub：相当于一个服务器，相比于国内的一些博客服务提供商要稳定安全，且靠谱的多。不会昨天还高喊「永久免费」今天就告诉你马上要停止服务了，快转移资料吧</li>
<li>Hexo：相当于博客框架（基于 Node.js），快速、简单，扩展插件较多，支持 Markdown 格式渲染</li>
<li>Next：博客主题，简洁、文档齐全且可定制性强，最重要的是全中文文档</li>
</ul>
<p>这三个组合在一起，真的是非常赞！</p>
<h2 id="更新记录"><a href="#更新记录" class="headerlink" title="更新记录"></a>更新记录</h2><p>2016-11-20 撰写初稿<br>2016-11-24 补充完善<br>2016-11-25 文章篇幅过长，将注册 GitHub 部分单独写一篇文章</p>
<h2 id="配置-GitHub"><a href="#配置-GitHub" class="headerlink" title="配置 GitHub"></a>配置 GitHub</h2><p>GitHub 需要注册才能使用，如果不会注册可以参考下面的文章，如果已注册请忽略：</p>
<blockquote>
<p>【注册 GitHub 详细步骤（图文）】</p>
<p><strong>鹿台</strong> <em><a href="https://shynhan.github.io/2016/11/27/注册-GitHub-详细步骤（图文）/">https://shynhan.github.io/2016/11/27/注册-GitHub-详细步骤（图文）/</a></em></p>
</blockquote>
<h3 id="创建静态主页"><a href="#创建静态主页" class="headerlink" title="创建静态主页"></a>创建静态主页</h3><ul>
<li>打开 <a href="https://github.com" target="_blank" rel="external">GtiHub 主页</a> 并登录。</li>
<li>新建一个项目<ul>
<li>如果你从未创建过项目点击 <code>Start a project</code> 按钮新建一个项目</li>
<li>对于创建过项目的人来说这一步很简单，就不扣图了。</li>
</ul>
</li>
</ul>
<p><img src="http://p1.bpimg.com/575659/27bc19d2ab5125c0.jpg" alt="GitHub_page1"></p>
<ul>
<li>上面的操作完成后跳转到一个新页面，先填写项目名称：<br><code>username.github.io</code><br>例如：<br><code>shynhan.github.io</code><br>这里的「shynhan」就是用户名，使用小写，即使你的用户名里有大写（我的用户名是「ShynHan」）字母也要转换成对应的小写字母，一定要写一致。</li>
<li>下面的项目描述随便填写</li>
<li>选择免费用户选择「Public」项目（默认项），付费用户可以根据自己需要选择「Private」项目</li>
<li>勾选上「Initialize this repository with a README」，创建「README」文档，方便测试</li>
<li>确认无误后点击<code>Create repository</code>按钮提交</li>
</ul>
<p><img src="http://p1.bpimg.com/575659/1e5307d93ab5dd9e.jpg" alt="GitHub_page2"></p>
<p><strong>至此，创建 GitHub 静态页面部分就完成了，新的静态页面需要十分钟左右初始化</strong></p>
<h3 id="配置-SSH-密钥"><a href="#配置-SSH-密钥" class="headerlink" title="配置 SSH 密钥"></a>配置 SSH 密钥</h3><p>并非必须，先留坑</p>
<h2 id="配置-Hexo"><a href="#配置-Hexo" class="headerlink" title="配置 Hexo"></a>配置 Hexo</h2><blockquote>
<p>Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 MarkDown（或其他渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页</p>
<p><strong>Hexo</strong> - <em><a href="https://hexo.io/zh-cn/docs/#什么是-Hexo？" target="_blank" rel="external">https://hexo.io/zh-cn/docs/#什么是-Hexo？</a></em></p>
</blockquote>
<p>关于 [Hexo][Hexo] 的配置推荐阅读 <a href="https://hexo.io/zh-cn/docs" target="_blank" rel="external">Hexo中文文档</a>，官方文档，十分全面，不过篇幅稍长，懒得看文档的可以看下面的步骤，基本是在官方文档里挑的一些重要且必要的内容，还有部分内容是我自己补充的。</p>
<h3 id="安装-Hexo"><a href="#安装-Hexo" class="headerlink" title="安装 Hexo"></a>安装 Hexo</h3><p>安装 <strong>Hexo</strong> 之前需要先安装下列应用程序：</p>
<ul>
<li><a href="https://nodejs.org" target="_blank" rel="external">Node.js</a></li>
<li><a href="https://git-scm.com" target="_blank" rel="external">Git</a></li>
</ul>
<p>如果你已经安装好了上列程序请点这里 <a href="#安装-Hexo-1">安装 Hexo</a></p>
<h4 id="安装-Git"><a href="#安装-Git" class="headerlink" title="安装 Git"></a>安装 Git</h4><blockquote>
<p>Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.</p>
<p><strong>Git</strong> - <em><a href="https://git-scm.com" target="_blank" rel="external">https://git-scm.com</a></em></p>
</blockquote>
<ul>
<li>Windows：到 <a href="https://git-scm.com/downloads" target="_blank" rel="external">Git下载页面</a> 下载对应版本的 Git 并安装。<br>如无特殊需求，安装过程中使用默认选项即可。</li>
<li>Linux（LinuxMint，Ubuntu，Debian）：在终端中运行下列命令<br><code>sudo apt-get install git-core</code></li>
</ul>
<p>安装完成后需要对 <strong>Git</strong> 进行简单的设置：</p>
<ul>
<li>在终端中输入<code>git --version</code>检查 Git 是否正确安装（这是查看 Git 版本的命令）</li>
<li>确认 Git 运行正常后输入<br><code>git config --global user.name &quot;自定义用户名&quot;</code><br>回车确定，如无任何反馈证明设置成功（Unix 哲学，没有现象就是好现象）</li>
<li>设置完用户名之后设置 Git 邮箱<br><code>git config --global user.email &quot;自定义邮箱地址&quot;</code><br>这里的邮箱地址推荐填写 GitHub 的绑定邮箱，这样在你使用 Git 向 GitHub 推送消息的时候会显示出你是项目管理者</li>
</ul>
<h4 id="安装-Node-js"><a href="#安装-Node-js" class="headerlink" title="安装 Node.js"></a>安装 Node.js</h4><blockquote>
<p>Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模型，使其轻量又高效。Node.js 的包管理器 npm，是全球最大的开源库生态系统。</p>
<p><strong>Node.js</strong> <em><a href="http://nodejs.cn" target="_blank" rel="external">http://nodejs.cn</a></em></p>
</blockquote>
<ul>
<li>Windows 系统推荐到 <a href="https://nodejs.org" target="_blank" rel="external">Node.js主页</a> 下载安装程序，我用的是<code>v6.9.1</code>版本，目前没问题，其他版本请自行测试。</li>
<li>Linux 系统推荐使用 <a href="https://github.com/creationix/nvm" target="_blank" rel="external">nvm</a>（Node.js版本管理器） 安装 Node.js<h5 id="通过-nvm-安装-Node-js"><a href="#通过-nvm-安装-Node-js" class="headerlink" title="通过 nvm 安装 Node.js"></a>通过 <strong>nvm</strong> 安装 <strong>Node.js</strong></h5></li>
</ul>
<p>下面以 Ubuntu 系统为例，使用 Windows 系统请到上面提供的地址下载 Node.js 安装程序，不需要使用 nvm 安装。</p>
<ol>
<li>安装 nvm<br>在终端中运行下列命令（这里与 <strong>Hexo中文文档</strong> 中的不同，我用 Hexo 中文文档提供的命令安装没有成功，所以我到 vnm 的 GitHub 项目主页找到了作者提供的方法）：</li>
</ol>
<p><code>wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash</code></p>
<p>或者</p>
<p><code>curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash</code></p>
<ol>
<li><p>修改终端配置，在终端的首选项中找到「以登录 Shell 方式运行命令」选中并重启终端。</p>
</li>
<li><p>安装 Node.js<br>在终端中运行下列命令（<code>v6.9.1</code>代表 Node.js 版本，可根据需要自行更换）：</p>
</li>
</ol>
<p><code>nvm install v6.9.1</code></p>
<p>安装成功后使用 <code>node -v</code> 命令查看是否安装成功。</p>
<h3 id="安装-Hexo-1"><a href="#安装-Hexo-1" class="headerlink" title="安装 Hexo"></a>安装 Hexo</h3><p>由于 npm 服务器在国外，国内访问速度很慢，而且链接还不稳定，推荐先更换成国内的镜像资源，如果不介意可以直接打开终端，输入下面命令安装 Hexo：</p>
<p><code>npm install -g hexo-cli</code></p>
<p>在终端中输入 <code>hexo --version</code> 检查是否安装成功。</p>
<h4 id="更换-npm-源"><a href="#更换-npm-源" class="headerlink" title="更换 npm 源"></a>更换 npm 源</h4><p>以下内容截取自 <a href="http://riny.net/2014/cnpm/" target="_blank" rel="external">国内优秀npm镜像推荐及使用</a></p>
<h5 id="国内优秀-npm-镜像"><a href="#国内优秀-npm-镜像" class="headerlink" title="国内优秀 npm 镜像"></a>国内优秀 npm 镜像</h5><ul>
<li>淘宝<ul>
<li>搜索地址：<a href="http://npm.taobao.org/" target="_blank" rel="external">http://npm.taobao.org/</a></li>
<li>registry地址：<a href="http://registry.npm.taobao.org/" target="_blank" rel="external">http://registry.npm.taobao.org/</a></li>
</ul>
</li>
<li>cnpmjs 镜像<ul>
<li>搜索地址：<a href="http://cnpmjs.org/" target="_blank" rel="external">http://cnpmjs.org/</a></li>
<li>registry地址：<a href="http://r.cnpmjs.org/" target="_blank" rel="external">http://r.cnpmjs.org/</a></li>
</ul>
</li>
</ul>
<h5 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h5><p>以淘宝源为例</p>
<ul>
<li>临时使用<br><code>npm --registry https://registry.npm.taobao.org install express</code></li>
<li>持久使用<br><code>npm config set registry https://registry.npm.taobao.org</code><ul>
<li>配置后可使用 <code>npm config get registry</code> 或 <code>npm info express</code> 命令验证是否成功</li>
</ul>
</li>
<li>通过 cnpm 使用<br><code>npm install -g cnpm --registry=https://registry.npm.taobao.org</code><ul>
<li>以后就可以使用 <code>cnpm</code> 来代替 <code>npm</code> 命令，同时原有 <code>npm</code> 命令不受影响，在国内源出现问题后可以继续使用国外源<br>示例：<br><code>cnpm install hexo-cli</code></li>
</ul>
</li>
</ul>
<h3 id="建站"><a href="#建站" class="headerlink" title="建站"></a>建站</h3><ul>
<li>新建一个用来存放博客内容的文件夹，比如 <code>D:/statci_page</code></li>
<li>打开终端输入 <code>cd D:/static_page</code> 切换到博客目录下</li>
<li>在终端中输入下面两个命令：<br><code>hexo init</code><br><code>npm install</code></li>
<li>上面的步骤都成功的话就可以在终端中输入<code>hexo s --debug</code> 命令启动本地服务器</li>
<li>用浏览器打开 <a href="http://localhost:4000/" target="_blank" rel="external">http://localhost:4000/</a> 查看效果</li>
</ul>
<p>如果你能打开一个博客，里面有一篇【Hello World】文章，说明你已经成功了<br>有时你可能打不开链接，但不代表失败，可以先看下面的步骤，把博客内容推送到 GitHub 再观察效果。</p>
<h2 id="将博客推送到-GitHub"><a href="#将博客推送到-GitHub" class="headerlink" title="将博客推送到 GitHub"></a>将博客推送到 GitHub</h2>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/GitHub/" rel="tag"># GitHub</a>
          
            <a href="/tags/Hexo/" rel="tag"># Hexo</a>
          
            <a href="/tags/Next/" rel="tag"># Next</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/11/27/注册-GitHub-详细步骤（图文）/" rel="prev" title="注册 GitHub 详细步骤（图文）">
                注册 GitHub 详细步骤（图文） <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/11/20/GitHub-Hexo-Next-搭建静态博客/"
           data-title="GitHub+Hexo+Next 搭建静态博客" data-url="https://shynhan.github.io/2016/11/20/GitHub-Hexo-Next-搭建静态博客/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/avatar.png"
               alt="玄鸟" />
          <p class="site-author-name" itemprop="name">玄鸟</p>
          <p class="site-description motion-element" itemprop="description">这里是思想的沃土，心灵的静修之地。</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">2</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">2</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/ShynHan" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        
          <div class="cc-license motion-element" itemprop="license">
            <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
              <img src="/images/cc-by-nc-sa.svg" alt="Creative Commons" />
            </a>
          </div>
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#更新记录"><span class="nav-number">2.</span> <span class="nav-text">更新记录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置-GitHub"><span class="nav-number">3.</span> <span class="nav-text">配置 GitHub</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#创建静态主页"><span class="nav-number">3.1.</span> <span class="nav-text">创建静态主页</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#配置-SSH-密钥"><span class="nav-number">3.2.</span> <span class="nav-text">配置 SSH 密钥</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置-Hexo"><span class="nav-number">4.</span> <span class="nav-text">配置 Hexo</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#安装-Hexo"><span class="nav-number">4.1.</span> <span class="nav-text">安装 Hexo</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#安装-Git"><span class="nav-number">4.1.1.</span> <span class="nav-text">安装 Git</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#安装-Node-js"><span class="nav-number">4.1.2.</span> <span class="nav-text">安装 Node.js</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#通过-nvm-安装-Node-js"><span class="nav-number">4.1.2.1.</span> <span class="nav-text">通过 nvm 安装 Node.js</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装-Hexo-1"><span class="nav-number">4.2.</span> <span class="nav-text">安装 Hexo</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#更换-npm-源"><span class="nav-number">4.2.1.</span> <span class="nav-text">更换 npm 源</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#国内优秀-npm-镜像"><span class="nav-number">4.2.1.1.</span> <span class="nav-text">国内优秀 npm 镜像</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#使用"><span class="nav-number">4.2.1.2.</span> <span class="nav-text">使用</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#建站"><span class="nav-number">4.3.</span> <span class="nav-text">建站</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#将博客推送到-GitHub"><span class="nav-number">5.</span> <span class="nav-text">将博客推送到 GitHub</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">玄鸟</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"sunman"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
      <script src="/js/src/hook-duoshuo.js?v=5.1.0"></script>
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  








  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PeL7ARXMlEXAsvPCdBf2jOR4-gzGzoHsz", "nXyIgRJ50YQUrjf3dn6YDSpF");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  


</body>
</html>
